package com.client.ryt.activity;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

import com.client.ryt.R;
import com.client.ryt.basic.BaseActivity;
import com.client.ryt.basic.BaseException;
import com.client.ryt.basic.BaseLiteners;
import com.client.ryt.basic.BaseResponse;
import com.client.ryt.basic.BaseTask;
import com.client.ryt.config.LoginConfig;
import com.client.ryt.entity.parameter.TradeRecordInfoParameters;
import com.client.ryt.entity.parameter.TradeRecordParameters;
import com.client.ryt.task.http.request.TradeRecordInfoRequest;
import com.client.ryt.task.http.response.TradeRecordInfoResponse;
import com.client.ryt.task.http.response.TradeRecordResponse;

public class TradeRecordInfoActivity extends BaseActivity {

    TradeRecordInfoActivity oThis= this;
    String statementid;
    TextView tv_shop_title;
    TextView tv_card_title;
    TextView tv_follow_id;
     TextView tv_trade_time;
    TextView tv_trade_goods;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_trade_record_info);
        Intent it = getIntent();
        if(it.hasExtra("statementid")){
            statementid = it.getStringExtra("statementid");
        }

         tv_shop_title = (TextView)findViewById(R.id.shop_title);
         tv_card_title = (TextView)findViewById(R.id.card_title);
         tv_follow_id = (TextView)findViewById(R.id.follow_id);
         tv_trade_time = (TextView)findViewById(R.id.trade_time);
         tv_trade_goods = (TextView)findViewById(R.id.trade_goods);

        TradeRecordInfoParameters tradeRecordInfoParameters = new TradeRecordInfoParameters();
        tradeRecordInfoParameters.setToken(LoginConfig.getLoginConfig().getToken());
        tradeRecordInfoParameters.setUsername(LoginConfig.getLoginConfig().getShopMember().getUsername());
        tradeRecordInfoParameters.setStatementid(Long.parseLong(statementid));
        new BaseTask<TradeRecordInfoRequest,TradeRecordInfoResponse>(oThis,TradeRecordInfoRequest.class,TradeRecordInfoResponse.class,tradeRecordInfoParameters,new BaseLiteners.BaseResponseListener() {
            @Override
            public void OnFail(BaseException e) {
                showToast(e.getErrmsg());
            }

            @Override
            public void OnSuccess(BaseResponse o) {
                TradeRecordInfoResponse tradeRecordInfoResponse = (TradeRecordInfoResponse)o;
                tv_card_title.setText(tradeRecordInfoResponse.getCard_title());
                tv_shop_title.setText(tradeRecordInfoResponse.getShop_title());
                tv_follow_id.setText(tradeRecordInfoResponse.getFollow_id());
                tv_trade_time.setText(tradeRecordInfoResponse.getTrade_time());
                tv_trade_goods.setText(tradeRecordInfoResponse.getTrade_goods());
            }
        },true).execute();


    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        //getMenuInflater().inflate(R.menu.menu_trade_record_info, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
